package com.google.guava.eventbus;

import com.google.common.eventbus.EventBus;
import com.google.guava.eventbus.listeners.ExceptionListener;

/**
 * @author fuc
 * @create 2020-10-06
 */
public class ExceptionEventBusExample {

  public static void main(String[] args) {
    final EventBus eventBus =
        new EventBus(
            (exception, context) -> {
              System.out.println(context.getEvent());
              System.out.println(context.getEventBus());
              System.out.println(context.getSubscriber());
              System.out.println(context.getSubscriberMethod());
            });
    eventBus.register(new ExceptionListener());
    eventBus.post("Exception Event");
  }

  /*static class ExceptionHandle implements SubscriberExceptionHandler {

    @Override
    public void handleException(Throwable exception, SubscriberExceptionContext context) {
      System.out.println(context.getEvent());
      System.out.println(context.getEventBus());
      System.out.println(context.getSubscriber());
      System.out.println(context.getSubscriberMethod());
    }
  }*/
}
